package org.desktop.web.shared.domain.entities;

import java.io.Serializable;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;


/**
 * The persistent class for the USERS database table.
 * 
 */
@Entity
@Table(name="USERS")
@NamedQuery(name="User.findAll", query="SELECT u FROM User u")
@JsonAutoDetect(fieldVisibility=Visibility.ANY)
@JsonIgnoreProperties(value={"timesheets","userLoggeds","usersProjects","password","emailss"})
@JsonInclude(Include.NON_NULL)
public class User implements Serializable, com.google.gwt.user.client.rpc.IsSerializable {
	private static final long serialVersionUID = 1L;
	private int id;
	private boolean firstLogin;
	private boolean locked;
	private String login;
	private byte[] password;
	private List<Timesheet> timesheets;
	@JsonProperty("emailss")
	private List<Email> emails;
	
	@JsonProperty("idCustomer")
	private CustomersEnabled customersEnabled;
	@JsonProperty("idRole")
	private Role role;
	private List<UsersLogged> usersLoggeds;
	private List<UsersProject> usersProjects;

	public User() {
	}


	@Id
	@Column(unique=true, nullable=false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	@Column(name="FIRST_LOGIN")
	public boolean getFirstLogin() {
		return this.firstLogin;
	}

	public void setFirstLogin(boolean firstLogin) {
		this.firstLogin = firstLogin;
	}


	public boolean getLocked() {
		return this.locked;
	}

	public void setLocked(boolean locked) {
		this.locked = locked;
	}


	@Column(length=45)
	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}


	@Lob
	public byte[] getPassword() {
		return this.password;
	}

	public void setPassword(byte[] password) {
		this.password = password;
	}


	//bi-directional many-to-one association to Timesheet
	@OneToMany(mappedBy="user")
	public List<Timesheet> getTimesheets() {
		return this.timesheets;
	}

	public void setTimesheets(List<Timesheet> timesheets) {
		this.timesheets = timesheets;
	}

	public Timesheet addTimesheet(Timesheet timesheet) {
		getTimesheets().add(timesheet);
		timesheet.setUser(this);

		return timesheet;
	}

	public Timesheet removeTimesheet(Timesheet timesheet) {
		getTimesheets().remove(timesheet);
		timesheet.setUser(null);

		return timesheet;
	}


	//bi-directional many-to-one association to CustomersEnabled
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ID_CUSTOMER", nullable=false)
	public CustomersEnabled getCustomersEnabled() {
		return this.customersEnabled;
	}

	public void setCustomersEnabled(CustomersEnabled customersEnabled) {
		this.customersEnabled = customersEnabled;
	}


	//bi-directional many-to-one association to Role
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ID_ROLE", nullable=false)
	public Role getRole() {
		return this.role;
	}

	public void setRole(Role role) {
		this.role = role;
	}


	//bi-directional many-to-one association to UsersLogged
	@OneToMany(mappedBy="user")
	public List<UsersLogged> getUsersLoggeds() {
		return this.usersLoggeds;
	}

	public void setUsersLoggeds(List<UsersLogged> usersLoggeds) {
		this.usersLoggeds = usersLoggeds;
	}

	public UsersLogged addUsersLogged(UsersLogged usersLogged) {
		getUsersLoggeds().add(usersLogged);
		usersLogged.setUser(this);

		return usersLogged;
	}

	public UsersLogged removeUsersLogged(UsersLogged usersLogged) {
		getUsersLoggeds().remove(usersLogged);
		usersLogged.setUser(null);

		return usersLogged;
	}


	//bi-directional many-to-one association to UsersProject
	@OneToMany(mappedBy="user")
	public List<UsersProject> getUsersProjects() {
		return this.usersProjects;
	}

	public void setUsersProjects(List<UsersProject> usersProjects) {
		this.usersProjects = usersProjects;
	}

	public UsersProject addUsersProject(UsersProject usersProject) {
		getUsersProjects().add(usersProject);
		usersProject.setUser(this);

		return usersProject;
	}

	public UsersProject removeUsersProject(UsersProject usersProject) {
		getUsersProjects().remove(usersProject);
		usersProject.setUser(null);

		return usersProject;
	}


	public List<Email> getEmails() {
		return emails;
	}


	public void setEmails(List<Email> emails) {
		this.emails = emails;
	}

}